import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';
import $ from "jquery";
import global from "./Global";


class GManager {
    constructor(elementId) {
        this.g = document.getElementById(elementId);
        try {
            var lic = this.g.new_LicenseServer;
            if (lic.enableTrial) {
                lic.enableTrial();
            }
            if (!this.g.project.create(null)) {
                alert("create project failed!");
                return false;
            }
            // global.g = this.g;
            // global.name = 'testname';
            return true;
        } catch (ex) {
            alert(ex.message);
            return false;
        }
    }

    showPanel(winParam = {}) {
        let param = {
            filePath: "E:\\WebProject\\Gg3d_v2\\code\\static\\bottom.html",
            offsetX: 0,
            offsetY: 100,
            sizeX: 100,
            sizeY: 200,
            resizable: false,
            hastitle: false,
            resetOnHide: "",
            position: global.gviHTMLWindowPosition.gviWinPosUserDefined,
            hideOnClick: false,
            winId: 0,
            transparence: 200,
            isPopupWindow: false
        };
        Object.assign(param,winParam);

        let wpfl = this.g.htmlWindow.createWindowParam();
        wpfl.filePath = param.filePath;
        wpfl.offsetX = param.offsetX;
        wpfl.offsetY =   param.offsetY;
        wpfl.sizeX =  param.sizeX;
        wpfl.sizeY =  param.sizeY;
        wpfl.resizable =  param.resizable;
        wpfl.hastitle =  param.hastitle;
        wpfl.resetOnHide =  param.resetOnHide;
        wpfl.position =  param.position;
        wpfl.hideOnClick =  param.hideOnClick;
        wpfl.winId =  param.winId;
        wpfl.transparence =  param.transparence;
        wpfl.isPopupWindow =  param.isPopupWindow;
        this.g.htmlWindow.setWindowParam(wpfl);
    }
}

export default GManager;

